package mode;

 abstract class Family {
    String memberName;
    //定义抽象方法
    public abstract void doingNow();
    public Family(String name) {
       memberName = name;
    }
}
class Mother extends Family{
     public Mother() {
         super("妈妈");
     }
     public void doingNow() {
         System.out.println(this.memberName+"正在给我做饭");
     }
     int age;
     public void cooking() {
         System.out.println("好想吃妈妈做的菜");
     }
}
class Father extends Family{
     public Father() {
         super("爸爸");
     }
     public void doingNow() {
         System.out.println(this.memberName+"正在看报纸");
     }
 }
 public class Test{
     public static void main1(String[] args) {
         //使用抽象类实现多态
        Family[] thisOne = {new Father(), new Mother()};
         for (Family one: thisOne) {
             one.doingNow();
         }
     }
 }

 class TestOne{
     public static void main(String[] args) {
         Mother mother = new Mother();
         mother.cooking();
         mother.doingNow();
         Family fmly = new Mother();
         //通过父类引用子类对象调用子类重写方法
         fmly.doingNow();
         //但是不能调用子类特有的方法
         //fmly.cooking();
     }
 }

